#pragma  once
#include "stdafx.h"
#include "units.h"
#include "scene.h"
#include "sensor.h"
#include "ui_fluid_model_editor.h"
#include "ui_fluid_model_add_form.h"
#include "common.h"
#include "parameters_model.h"

class QGraphicsSceneMouseEvent;
class SceneView;
class Common;
class ConnectionPoint;
class Connector;
class Title;
class ParametersModel;
class Indicator;
class Sensor;
class Delegate;

class FluidModel : public QObject
{
	Q_OBJECT
	static const enum type_t {OIL, GAS, COMPOSITION};
public:
	FluidModel(Common* _common, const QString &_name, const int &_type);
	~FluidModel();
	void init_model();
	ParametersModel* model;
	QString getName(){ return name;}
	type_t getType(){ return type; }
	int getIntType(){ return (int)type; }
	bool isOil(){ return type == OIL; }
	bool isGas(){ return type == GAS; }
	bool isComposition(){ return type == COMPOSITION; }
private:
	Common* common;
	QString name;
	type_t type;
private slots:
	void update_parameters();
	void getNewParameterValue(const QString &_name, const QVariant &_value);
signals:
	void setModelData(const int &parent_row, const int &row, const QVariant &value);
	void setNewParameterValue(const QString &_name, const QVariant &_value);
};

class FluidModelEitor : public QDialog
{
	Q_OBJECT
private:
	Ui::FluidModelEitorDialog ui;
	Common* common;
	void setModel(ParametersModel* _model);
	vector<FluidModel*> FluidModelList;
public:
	FluidModelEitor(Common* _common);	
	~FluidModelEitor();
	void setData(vector<FluidModel*> _FluidModelList, const QString _current_fluid);
	vector<FluidModel*> getData();
	QString getCurrentFluidModelName();
	private slots:
		void on_bAdd_clicked();
		void on_bRemove_clicked();
		void on_bUse_clicked();
		void displayFluidModel(int index);
};

class FluidModelAddForm : public QDialog
{
	Q_OBJECT
private:
	Ui::FluidModelAddFormDialog ui;
public:
	FluidModelAddForm(QWidget* pwgt = 0);	
	~FluidModelAddForm();
	pair<QString, int> getData();
	private slots:
};